//
//  UILabel+FRP.m
//  Pods
//
//  Created by kepuna on 2017/10/18.
//
//

#import "UILabel+FRP.h"

@implementation UILabel (FRP)

+ (instancetype)nx_initWith:(void (^)(UILabel *label))initBlock {
    UILabel *label = [[UILabel alloc]init];
    if (initBlock) {
        initBlock(label);
    }
    return label;
}

- (UILabel *(^)(CGRect))nx_frame {
    return ^UILabel*(CGRect frame) {
        self.frame = frame;
        return self;
    };
}

- (UILabel *(^)(UIView *))nx_addInView {
    return ^UILabel *(UIView *view) {
        [view addSubview:self];
        return self;
    };
}

- (UILabel *(^)(NSString *))nx_text {
    return ^UILabel *(NSString *text) {
        self.text = text;
        return self;
    };
}

- (UILabel *(^)(UIColor *))nx_textColor {
    return ^UILabel *(UIColor *color) {
        self.textColor = color ;
        return self;
    };
}

- (UILabel *(^)(UIColor *))nx_backgroundColor {
    return ^UILabel *(UIColor *color) {
        self.backgroundColor = color;
        return self;
    };
}

- (UILabel *(^)(CGFloat))nx_fontSize {
    return ^UILabel *(CGFloat value) {
        self.font = [UIFont systemFontOfSize:value];
        return self;
    };
}

- (UILabel *(^)(NSTextAlignment))nx_textAlignment {
    return ^UILabel *(NSTextAlignment alignment) {
        self.textAlignment = alignment;
        return self;
    };
}

- (UILabel *(^)(NSInteger))nx_numberLine {
    return ^UILabel *(NSInteger numberLine) {
        self.numberOfLines = numberLine;
        return self;
    };
    
}

- (UILabel *(^)(NSString *, CGFloat))nx_textName {
    return ^UILabel *(NSString *name ,CGFloat fontSize) {
        self.font = [UIFont fontWithName:name size:fontSize];
        return self;
    };
}

- (UILabel *(^)(UIColor *, CGFloat))nx_border {
    return ^UILabel *(UIColor *color,CGFloat width) {
        self.layer.borderColor = color.CGColor;
        self.layer.borderWidth = width;
        self.layer.masksToBounds = YES;
        return self;
    };
}

- (UILabel *(^)(CGFloat))nx_cornerRadius {
    return ^UILabel *(CGFloat cornerRadius) {
        self.layer.cornerRadius = cornerRadius;
        self.layer.masksToBounds = YES;
        return self;
    };
}

@end
